/*
 * @Author: Jiraiya
 * @Date: 2020-03-03 20:47:57
 * @LastEditors: Jiraiya
 * @LastEditTime: 2020-03-03 21:09:17
 * @Description: 
 */
//🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏
//Set接受iterator接口
const a = new Set('abc')
console.log(a)//Set { 'a', 'b', 'c' }
console.log(a.size) // 3

//NaN相等
a.add(NaN)
a.add(NaN)
console.log(a.size) // 4

a.delete(NaN)
console.log(a) // Set { 'a', 'b', 'c' }
console.log(a.has(NaN))// false
a.clear()
console.log(a)// Set {}

// for...of keys values entries forEach map filter

//🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏
// WeakSet只能放置对象
const a = [1, 2], b = [3, 4]
const c = new WeakSet()
c.add(a)
c.add(b)
//只有has delete add方法
console.log(c.has(a), c.has(b))// true true

//🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏
// Map
const a = new Map()
const obj = {}
a.set(obj, 1)
console.log(a.get(obj))//1
a.delete(obj)
console.log(a.has(obj))//false

a.clear()
console.log(a.size)//0

// keys values entries forEach map filter
const b = new Map([['a', 1], ['b', 2]])
console.log(b) //Map { 'a' => 1, 'b' => 2 }
console.log([...b]) //[ [ 'a', 1 ], [ 'b', 2 ] ]

//🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏
//WeakMap只能接受对象作为key
// get set delete has